//与移动端交互的状态管理
export const UPDATA_INTERACTIVE = 'UPDATA_INTERACTIVE' //更新状态管理中的值
export const PUSH_MWSSAGENOTIFY = 'PUSH_MWSSAGENOTIFY' //添加推送
export const UPDATA_MWSSAGENOTIFY = 'UPDATA_MWSSAGENOTIFY' //更新推送
export const CLEAR_MWSSAGENOTIFY = 'CLEAR_MWSSAGENOTIFY' //更新清空

export const PUSH_WINNOTICE = 'PUSH_WINNOTICE'  //  添加中奖通知
export const SHIFT_WINNOTICE = 'SHIFT_WINNOTICE'  //  删除中奖通知


export default {
    state:{
        statusBarHeight:{height:'1.36rem',tabBarHeight:'0'},
        as:{channel:''},   //初始化时获取加载渠道来源（安卓，iOS，浏览器）（0：安卓 1：iOS）
        token:'',   //是否从移动端端获取token
        weChatPayNotify:'', //微信支付回调
        alipayPayNotify:'', //支付宝支付回调
        weChatAuthState:'', //我的资料页面同步微信资料回调
        Location:{la: '0', lo: '0',addressText:'上海市'},//经纬度 la : 纬度  lo 经度
        LocationByDetail:{la: '0', lo: '0',addressText:'上海市'},//经纬度 la : 纬度  lo 经度
        LocationByAddress:{la: '0', lo: '0',addressText:'上海市'},//经纬度 la : 纬度  lo 经度
        image:{url:''},  //交互返回的图片信息,
        wx_info:{}, //微信返回的资料
        payStatus:{payState:''},
        walletPayStatus:{payState:''},
        shouState:{type:false},
        jpushMessageNotify:JSON.parse(localStorage.getItem('jpushMessageNotify'))||{arr:[]},
        walletPay:{type:false},
        pushShopDetails:{},
        refreshMyPage:{type:false,flag:''},
        IsClearSetinterval:{type:"0"},
        refreshUserInfo:{flang:false}, //app.vue页面是否请求一次用户资料
        checkIsNewEdition:{type:true},   //查看是否是新版本的App
        qyMsgCount:{qyMsgCount:0}, //七鱼客服未读数
        versionName:{versionName:''},
        isnativeqy: {isNativeQy: false},   //  true走原声吊起客服
        winNotice: [],
        startWave: {startWave:false}
    },
    mutations: {
        [UPDATA_INTERACTIVE](state, data) {
            state[data.type] =  data.content;
        },
        [PUSH_MWSSAGENOTIFY](state, data) {
            if (data.subType == '10101' || data.subType == '10102'){
                return ;
            }
            let arr = state.jpushMessageNotify.arr
            arr.push(data)
            state.jpushMessageNageNotify={arr: arr};
            localStorage.setItem('jpushMessageNotify',JSON.stringify(state.jpushMessageNotify));
        },
        [CLEAR_MWSSAGENOTIFY](state) {
            state.jpushMessageNotify.arr = [];
            localStorage.setItem('jpushMessageNotify',JSON.stringify(state.jpushMessageNotify));
        },
        [UPDATA_MWSSAGENOTIFY](state, data) {
            if(data == 0){
                state.jpushMessageNotify.arr=state.jpushMessageNotify.arr.filter(v => v.type != "10000" )
            }else if(data == 1){
                state.jpushMessageNotify.arr=state.jpushMessageNotify.arr.filter(v => v.type != "20000" )
            }else if(data == 2){
                state.jpushMessageNotify.arr=state.jpushMessageNotify.arr.filter(v => v.type != "30000")
            }else if(data == 3){
                state.jpushMessageNotify.arr=state.jpushMessageNotify.arr.filter(v => v.type != "50000")
            }
            localStorage.setItem('jpushMessageNotify',JSON.stringify(state.jpushMessageNotify));
        },
        [PUSH_WINNOTICE](state, data) {
            state.winNotice.push(data);
            localStorage.setItem('jpushMessageNotify',JSON.stringify(state.jpushMessageNotify));
        },
        [SHIFT_WINNOTICE](state, data) {
            state.winNotice.shift(data);
            localStorage.setItem('jpushMessageNotify',JSON.stringify(state.jpushMessageNotify));
        },
    },
    actions: {
        [UPDATA_INTERACTIVE]({commit}, data) {

            commit(UPDATA_INTERACTIVE, data)
        },
        [PUSH_MWSSAGENOTIFY]({commit}, data) {

            commit(PUSH_MWSSAGENOTIFY, data)
        },
        [UPDATA_MWSSAGENOTIFY]({commit}, data) {

            commit(UPDATA_MWSSAGENOTIFY, data)
        },
        [CLEAR_MWSSAGENOTIFY]({commit}) {

            commit(CLEAR_MWSSAGENOTIFY)
        },
        [PUSH_WINNOTICE]({commit}) {
            commit(PUSH_WINNOTICE)
        },
        [SHIFT_WINNOTICE]({commit}) {
            commit(SHIFT_WINNOTICE)
        }
    }
}